package com.cn.qtms.dao;//类注释设置模板

import com.cn.qtms.base.dao.BaseDao;
import com.cn.qtms.entity.TsAttachment;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Name:TsAttachmentDao
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-09-19 16:28
 **/
@Repository
public interface TsAttachmentDao extends BaseDao<TsAttachment,Long> {
    /**
     * 查询文件集合
     * @param relatedTable
     * @param relatedId
     * @param fileType
     * @return
     */
    @Query(" from  TsAttachment where relatedTable=:relatedTable and relatedId=:relatedId and fileType=:fileType")
    List<TsAttachment> findTsAttachments(@Param("relatedTable") String relatedTable, @Param("relatedId") Long relatedId, @Param("fileType") String fileType);

    /**
     * 根据文件名查出文件路径
     * @param path
     * @return
     */
    @Query("from  TsAttachment where fileName=:path")
    TsAttachment findAttachment(@Param("path") String path);

}
